package com.annhoa.infrastructure.listener;

import java.util.logging.Logger;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import org.springframework.web.context.support.WebApplicationContextUtils;

import com.annhoa.infrastructure.consts.Const;

/**
 * Application Lifecycle Listener implementation class WEBAppContextListener
 *
 */
@WebListener
public class WEBAppContextListener implements ServletContextListener {
	
	private static Logger logger = Logger.getLogger(WEBAppContextListener.class.toString());
    /**
     * Default constructor. 
     */
    public WEBAppContextListener() {
        // TODO Auto-generated constructor stub
    }

	/**
     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
     */
	@Override
    public void contextDestroyed(ServletContextEvent arg0)  { 
    	logger.warning("线程池关闭中...");
    }

	/**
     * @see ServletContextListener#contextInitialized(ServletContextEvent)
     */
	@Override
    public void contextInitialized(ServletContextEvent event)  { 
    	logger.info("开启web容器...");
		Const.WEB_APP_CONTEXT = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
		}
	
}
